package com.bsoft.exchange.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bsoft.exchange.dao.his.PriceMapper;
import com.bsoft.exchange.domain.ListFyDomain;
import com.bsoft.exchange.domain.ListYpDomain;
import com.bsoft.exchange.domain.QueryDrugs;
import com.bsoft.exchange.domain.QueryTreatment;
import com.bsoft.exchange.pojo.PricePojo;

@Service
public class QueryPriceService {
	@Autowired
	PriceMapper priceMapper;
	/**
	 * 获取药品价格
	 * @param hospitalCode
	 * @param query
	 * @param pageNo
	 * @param pageSize
	 * @return
	 */
//	public List<QueryDrugs> queryDrugs(String hospitalCode,String query,int pageNo,int pageSize){
	public List<QueryDrugs> queryDrugs(PricePojo pricePojo){
		String hospitalCode = pricePojo.getOrganizationId();
		String query = pricePojo.getQuery();
		int pageNo = pricePojo.getPageNo();
		int pageSize = pricePojo.getPageSize();
//		List<QueryDrugs> listQueryDrugs = priceMapper.getCountYp(hospitalCode);
		String countYp = String.valueOf(priceMapper.getCountYp(hospitalCode));
		List<ListYpDomain> listYp = priceMapper.getListYp(hospitalCode, query, pageNo, pageSize);
		QueryDrugs queryDrug = new QueryDrugs();
		queryDrug.setTotal(countYp);
		queryDrug.setList(listYp);
		List<QueryDrugs> queryDrugs = new ArrayList<QueryDrugs>();
		queryDrugs.add(queryDrug);
//		for(int i = 0 ; i < department.size() ; i++) {
//			  String departmentcode;
//			  departmentcode = department.get(i).getParentDepartmentCode();
//			  List<ChildDepartment> childdepartment = departmentMapper.selectListChild(hospitalCode,departmentcode);
//			  department.get(i).setDepartmentList(childdepartment);;
//			}
		return queryDrugs;
		
	}
	/**
	 * 获取诊疗价格
	 * @param hospitalCode
	 * @param query
	 * @param pageNo
	 * @param pageSize
	 * @return
	 */
	public List<QueryTreatment> queryTreatment(PricePojo pricePojo){
		String hospitalCode = pricePojo.getOrganizationId();
		String query = pricePojo.getQuery();
		int pageNo = pricePojo.getPageNo();
		int pageSize = pricePojo.getPageSize();
		String countFy = String.valueOf(priceMapper.getCountFy(hospitalCode));
		List<ListFyDomain> listFy = priceMapper.getListFy(hospitalCode, query, pageNo, pageSize);
		QueryTreatment queryTreatments = new QueryTreatment();
		queryTreatments.setTotal(countFy);
		queryTreatments.setList(listFy);
		List<QueryTreatment> queryTreatment = new ArrayList<QueryTreatment>();
		queryTreatment.add(queryTreatments);

		return queryTreatment;
		
	}

}